import React from 'react';
import { Toast, } from 'antd-mobile';

export default class Index extends React.Component {
    constructor(props){
        super(props)
        this.state={
			flower: 0,
            rmb: 0,
            uinfo: [],
            data: [],
            fl:0
		}
    }
	componentDidMount(){
		document.title = '年费会员'
        global.Ajax.hhtc_request('year/infos',{}).then(data=>{
			if(data.code===1){
                this.setState(data.data)
			}
		})
	}
	render(){
		return(
			<div style={{height: '100vh',background: '#F5F5F5',}}>
                <div className='vip_top'>
                    <img alt='' src={this.state.uinfo.avatar} alt='' />
                    <div>
                        <h1>{this.state.uinfo.nickname}，您好！</h1>
                        <p>年费会员课程免费学~</p>
                        {this.state.uinfo.level!=3&&<span onClick={()=>{this.props.history.push('/page/home/user/payvip')}}>开通年费会员</span>}
                        {this.state.uinfo.level===3&&<p>{this.state.uinfo.out_time}到期</p>}
                    </div>
                </div>
                <div className='yaoq_box'>
                    <h1>邀请有奖</h1>
                    <div className='item'>
                        <img alt='' src={require('../../imgs/yq1.png')} />
                        <div>
                            <h2>邀请两位好友</h2>
                            <p>获得支付金额的积分返利</p>
                        </div>
                        {this.state.uinfo.is_full_rebate===0&&this.state.uinfo.level===3&&<p className='wei'>未获得</p>}
                        {this.state.uinfo.is_full_rebate===1&&<p className='wei'>已获得</p>}
                        {this.state.uinfo.level!==3&&<p className='wei'>您未购买</p>}
                    </div>
                    <div className='item'>
                        <img alt='' src={require('../../imgs/yq2.png')} />
                        <div>
                            <h2>邀请三位好友</h2>
                            <p>获赠年费会员</p>
                        </div>
                        {this.state.uinfo.is_free_vip===0&&this.state.uinfo.rebate_num<3&&this.state.uinfo.level!==3&&<p className='yi'>{this.state.uinfo.xj}/3</p>}
                        {this.state.uinfo.is_free_vip===1&&this.state.uinfo.level!==3&&<p className='wei'>已获得</p>}
                    </div>
                    <div className='item'>
                        <img alt='' src={require('../../imgs/yq3.png')} />
                        <div>
                            <h2>邀请购买会员</h2>
                            <p>获得{this.state.fl}%积分返利</p>
                        </div>
                        <span>已获得{this.state.uinfo.rebate_num}次</span>
                    </div>
                </div>
				{this.state.data.map((item,index)=>{
					return(
						item.data.length>0&&<React.Fragment key={'data'+index}>
							<div className='title_box'>
								<h1>{item.title}</h1>
								<p onClick={()=>{this.props.history.push('/page/home/home/classify/'+item.id)}}>
									<span>更多</span>
									<img alt='' src={require('../../imgs/r2.png')} />
								</p>
							</div>
							<div className='sy_list'>
								{item.data.map((child,k)=>{
									return(
										<div className='item' key={'child'+k} onClick={()=>{this.props.history.push('/page/home/learn/learndetail/'+child.id)}}>
											<div className='picbox'>
												<img alt='' src={child.img} className='pic' />
												<p className='bq'>{child.type===1?'视频':'听书'}</p>
											</div>
											<p className='title'>{child.title}</p>
										</div>
									)
								})}
							</div>
						</React.Fragment>
					)
				})}
			</div>
		)
	}
}
